package userwashlogic

import (
	"context"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/model/userwash"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LastUserWashDescLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLastUserWashDescLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LastUserWashDescLogic {
	return &LastUserWashDescLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LastUserWashDescLogic) LastUserWashDesc(in *rpc.LastUserWashDescRequest) (*rpc.LastUserWashDescResponse, error) {
	resp := &rpc.LastUserWashDescResponse{}
	userWashDesc, err := userwash.NewUserWashDescModel(l.ctx, l.svcCtx.Db).Last(in.Language)
	if err != nil {
		return nil, err
	}
	resp.Data = &rpc.UserWashDescData{
		Id:          userWashDesc.ID,
		CreatedAt:   userWashDesc.CreatedAt,
		UpdatedAt:   userWashDesc.UpdatedAt,
		Status:      userWashDesc.Status,
		AccountId:   userWashDesc.AccountId,
		Language:    userWashDesc.Language,
		Description: userWashDesc.Description,
	}
	return resp, nil
}
